<?php
/**
 * Created by PhpStorm.
 * User: Admin
 * Date: 2020-08-08
 * Time: 下午 12:48
 */

namespace Lib;

abstract class Config {
    protected $_data;
    protected $_default =  [
        'hashkey' => '20200808',
        'internal_name' => '_download_files',
        'share_path_name' => 'share',
        'shared_path_name' => 'shared',
    ];
    
    protected function parse($file) {
        return [];
    }
    
    public function __construct($file) {
        $data = $this->parse($file);
        
        foreach ($data as $key => &$value) {
            if(!$value) {
                $value = $this->_default[$key];
            }
        }
        
        $this->_data = array_merge($this->_default, $data);
    }
    
    public function getInternalName() {
        return $this->_data['internal_name'];
    }
    
    public function getHashkey() {
        return $this->_data['hashkey'];
    }
    
    public function get($key) {
        return $this->_data[$key];
    }
    
    public function getSharedPathName() {
        return $this->_data['shared_path_name'];
    }

    public function getSharePathName() {
        return $this->_data['share_path_name'];
    }
    
        // public function get() {
    //     return $this->_data[''];
    // }
    
    
}